$(function(){
    $.fn.swim = function(options){
        this.each(function(i,ele){
            zkxx(ele,options)
        })
        return this
    }
    var zkxx = function(ele,options){
        var defs = {
            type:'Y-m-d H:i:s',
            spanClass:'box',
            time:m
        }
        var sets = $.extend(defs,options)
        var $ele = $(ele)
        console.log($ele)
        var $span = $('.' + sets.spanClass,$ele)
        console.log($span)
        var t,y,m,d,h,i,s;
        function change(timestamp){
           if(timestamp.length == 10){
               t = timestamp ? new Date(timestamp*1000) : new Date()
           }else{
               t = timestamp ? new Date(timestamp) : new Date()
           }
                
                y = t.getFullYear()
                m = t.getMonth() + 1
                d = t.getDate()
                h = t.getHours()
                i = t.getMinutes()
                s = t.getSeconds()
        }
        function data1(){
                change(sets.time)
                return y + '年' + (m < 10 ? '0' + m : m) + '月' + (d < 10 ? '0' + d : d) + '日'
                + (h < 10 ? '0' + h : h) + ':'+ (i < 10 ? '0' + i : i) + ':'+ (s < 10 ? '0' + s : s) 
        }
        function data2(){
                change(sets.time)
                return y + '年' + (m < 10 ? '0' + m : m) + '月' + (d < 10 ? '0' + d : d) + '日'
        }
        if(sets.type == 'Y-m-d H:i:s'){
            $span.html(data1())
        }else if(sets.type == 'Y-m-d'){
            $span.html(data2())
        }
    }
})